'use strict';

const { Controller } = require('egg');
class userController extends Controller {
	// 资源
	async index() {
		const service = this.ctx.service.userService;
		return await service.index();
	}
	// 更新资源
	async update() {
		const { ctx } = this;
		const id = ctx.params.id;
		const data = ctx.request.body;
		const service = ctx.service.userService;
		// 允许修改的字段
		const allowFields = ['name', 'mobile', 'status', 'avatar'];
		const updateData = this.ctx.helper.filterData(data, allowFields);
		return service.success(await service.update(id, updateData));
	}
}
module.exports = userController;